import fs from 'fs'
import {Controller} from '../Config/setting.js'
import url from 'url';

const getPath = (file) => {
    let filePath = new URL(`../${file}`, import.meta.url).href;
    let newfilePath = url.fileURLToPath(filePath)
    return newfilePath
}

export const getControllers = function () {
    const controllerUrl = getPath(Controller)

    console.log(`Text! getControllers : ${controllerUrl}`);

    let fileArr = fs.readdirSync(controllerUrl).filter(item => item.endsWith('info.js'));
    let ControllerPath = fileArr.map(item => `file:///${controllerUrl}/${item}`);
    console.log(`Text! ControllerPath : ${ControllerPath}`);
    return ControllerPath
}

export default getPath;